---
category: Array
contributors:
    - jonrandy
created: '2020-04-23'
title: Convert an array of strings to numbers
updated: '2021-10-13'
---

**JavaScript version**

```js toNumbers.js
const toNumbers = (arr) => arr.map(Number);

// Or
const toNumbers = (arr) => arr.map((x) => +x);
```

**TypeScript version**

```ts toNumbers.ts
const toNumbers = (arr: string[]): number[] => arr.map(Number);

// Or
const toNumbers = (arr: string[]): number[] => arr.map((x) => +x);
```

**Example**

```js example.js
toNumbers(['2', '3', '4']); // [2, 3, 4]
```
